package com.example.yur;


import com.example.fragment.CenterFragment;
import com.example.fragment.LeftFragment;

import com.example.view.SlidingMenu;

import android.os.Bundle;
import android.app.Activity;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentTransaction;
import android.view.Menu;
import android.view.View;

public class MainActivity extends FragmentActivity {
	
	private SlidingMenu mSlidingMenu;
	private LeftFragment mLeftFragment;
	private CenterFragment mCenterFragment;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main);
		findView();
		initView();
		
	}
	
	public void findView(){
		mSlidingMenu=(SlidingMenu)findViewById(R.id.slidingMenu1);
	}
	
	public void initView(){
		
		View leftView=View.inflate(this, R.layout.framelayout_left, null);
		View centerView=View.inflate(this, R.layout.framelayout_center, null);
		
		mSlidingMenu.setView(leftView, centerView, 200);
		
		FragmentTransaction transaction = getSupportFragmentManager()
				.beginTransaction();
		mLeftFragment = new LeftFragment();
		transaction.replace(R.id.fl_left, mLeftFragment);
		mCenterFragment = new CenterFragment();
		transaction.replace(R.id.fl_center, mCenterFragment);
		transaction.commit();
		mSlidingMenu.setWhichSideCanShow(true);
		
	}

	public void showLeftViewToogle() {
		mSlidingMenu.showLeftViewToogle();
	}

	public void setText(String text){
		mCenterFragment.setText(text);
	}
	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.main, menu);
		return true;
	}

}
